<%@ page language="java" contentType="text/html"  pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="lcfms" uri="/WEB-INF/tld/lcfms.tld" %>	
<!DOCTYPE html>																	
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="stylesheet" href="${CSS}bootstrap.min.css">
		<link rel="stylesheet" href="${CSS}iconfont.css">
		<link rel="stylesheet" href="${CSS}form.css">
		<link rel="stylesheet" href="${CSS}kalendae.css"/>
		<script src="${JS}jquery-3.2.1.min.js"></script>
		<script src="${JS}../../layer/layer.js"></script>
		<script src="${JS}bootstrap.min.js"></script>
		<script src="${JS}kalendae.js"></script>	
		<script src="${JS}form.js"></script>
		<script src="${JS}alert.js"></script>
		<style>		
		.form-footer>.form-group{
			margin-left:0;
	    	margin-right:0;
		}
		.form-box{
			border:0;
		}		
		.form-horizontal .control-label {
		    padding: 7px 2px;
		    margin-bottom: 0;
		    text-align: right;
		}
		</style>
	</head>
	<body>
		<div class="container-fluid">
			<div class="row">
				<div class="form-box">
					<form class="form-horizontal" name="myform"  method="${method}" action="${action}">		            	
						<div class="form-body">
						    <c:forEach var="iy" begin="0" end="${form.size()}">						  
							<c:forEach items="${form}" var="val">						
							<c:if test="${val.sort == iy}">		
							<%-- text类型   --%>						
							<c:if test="${val.type eq 'text'}">
							<div class="form-group">
								<div class="col-xs-12">${val.text}</div>
							</div>
							</c:if>			
							<%-- hidden类型   --%>						
							<c:if test="${val.type eq 'hidden'}">
							<input type="hidden" name="${val.name}" value="${val.value}"/>
							</c:if>
							<%-- jspview类型 --%>
							<c:if test="${val.type eq 'jspview'}">
							<jsp:include page="../${val.file}"/>
							</c:if>
							<%-- input类型 --%>
							<c:if test="${val.type eq 'input'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
									<input class="form-control" name="${val.name}" type="text" value="${val.value}" attribute="${val.validate}" placeholder="请输入${val.title}"
									<lcfms:if test="${val.readonly != null}">readonly</lcfms:if>	
									/>						
								</div>
							</div>
							</c:if>
							<%-- inputbutton类型 --%>
							<c:if test="${val.type eq 'inputbutton'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">								    
									<input class="form-control" name="${val.name}" type="text" value="${val.value}" attribute="${val.validate}" placeholder="请输入${val.title}"
									<lcfms:if test="${val.readonly != null}">readonly</lcfms:if>	
									/>				
									<input type="button" value="${val.button}" class="btn btn-input btn-primary" onclick="${val.function}"/>
								</div>
							</div>
							</c:if>
							<%-- editor类型 --%>
							<c:if test="${val.type eq 'editor'}">
							<jsp:include page="../kindeditor.jsp">
							    <jsp:param name="type" value="layer"/>
								<jsp:param name="title" value="${val.title}"/>
								<jsp:param name="name" value="${val.name}"/>
								<jsp:param name="value" value="${val.value}"/>
							</jsp:include>
							</c:if>
							<%-- uploadImg类型 --%>
							<c:if test="${val.type eq 'uploadImg'}">
							<jsp:include page="../imageupload.jsp">
							    <jsp:param name="type" value="layer"/>
								<jsp:param name="title" value="${val.title}"/>
								<jsp:param name="name" value="${val.name}"/>
								<jsp:param name="value" value="${val.value}"/>
								<jsp:param name="minFiles" value="${val.minFiles}"/>
								<jsp:param name="maxFiles" value="${val.maxFiles}"/>
							</jsp:include>
							</c:if>
							<%-- uploadFile类型 --%>
							<c:if test="${val.type eq 'uploadFile'}">
							<jsp:include page="../fileupload.jsp">
							    <jsp:param name="type" value="layer"/>
								<jsp:param name="title" value="${val.title}"/>
								<jsp:param name="name" value="${val.name}"/>
								<jsp:param name="value" value="${val.value}"/>
								<jsp:param name="fileType" value="${val.fileType}"/>
								<jsp:param name="fileSize" value="${val.fileSize}"/>							
								<jsp:param name="minFiles" value="${val.minFiles}"/>
								<jsp:param name="maxFiles" value="${val.maxFiles}"/>
							</jsp:include>
							</c:if>
							<%-- textarea类型 --%>
							<c:if test="${val.type eq 'textarea'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
									<textarea class="form-control" name="${val.name}" rows="3" cols="50" maxnum="${val.maxnum}">${val.value}</textarea>					
								</div>
							</div>
							</c:if>
							<%-- areas类型 --%>
							<c:if test="${val.type eq 'areas'}">
							<jsp:include page="../areas.jsp">
								<jsp:param name="title" value="${val.title}"/>
								<jsp:param name="level" value="${val.level}"/>
								<jsp:param name="s_province" value="${val.defaultValue[0]}"/>
								<jsp:param name="s_city" value="${val.defaultValue[1]}"/>
								<jsp:param name="s_county" value="${val.defaultValue[2]}"/>
								<jsp:param name="s_street" value="${val.defaultValue[3]}"/>
							</jsp:include>
							</c:if>
							<%-- dateslice类型 --%>
							<c:if test="${val.type eq 'dateslice'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
								    <div class="row">
								    	<div class="col-xs-4"><input readonly="readonly" class="form-control calendar" value="${val.begin}" name="calendar" type="text" months="1" mode="single" direction="${direction}"></div>
								    	<div class="col-xs-1" style="text-align:center;padding:0;"><span style="position:relative;top:5px;">到</span></div>
								    	<div class="col-xs-4"><input readonly="readonly" class="form-control calendar" value="${val.end}" name="calendar" type="text" months="1" mode="single" direction="${direction}"></div>
								    </div>						
								</div>
							</div>							
							</c:if>
							<%-- timeslice类型 --%>
							<c:if test="${val.type eq 'timeslice'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
								 					
								</div>
							</div>							
							</c:if>
							<%-- date类型 --%>
							<c:if test="${val.type eq 'date'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
								<input readonly="readonly" class="form-control calendar" value="${val.value}" name="calendar" type="text" months="1" mode="single" direction="${direction}">      					
								</div>
							</div>							
							</c:if>
							<%-- select类型 --%>
							<c:if test="${val.type eq 'select'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
									<select class="form-control" name="${val.name}">
										<c:set var="i" value="0"/>	
										<c:forEach items="${val.value}" var="option">																		
										<option value="${option}" <c:if test="${val.def eq option}">selected</c:if>>
										<c:out value="${val.text[i]}"/>								
										</option>
										<c:set var="i" value="${i+1}"/>	
										</c:forEach>										
									</select>
								</div>
							</div>
							</c:if>	
							<%-- radio类型 --%>
							<c:if test="${val.type eq 'radio'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
									<div class="form-control radio">
										<c:set var="i" value="0"/>	
										<c:forEach items="${val.value}" var="_radio">																		
										<label class="radio-inline">
											<input name="${val.name}" type="radio" value="${_radio}" <c:if test="${val.def eq _radio}">checked="checked"</c:if>>
											<span class="lbl">
												<c:out value="${val.text[i]}"/>	
											</span>
										</label>						
										<c:set var="i" value="${i+1}"/>	
										</c:forEach>													
									</div>
								</div>
							</div>
							</c:if>	
							<%-- checkbox类型 --%>
							<c:if test="${val.type eq 'checkbox'}">
							<div class="form-group">
								<label class="col-xs-3 control-label">${val.title}：</label>
								<div class="col-xs-9">
									<div class="form-control checkbox">
										<c:set var="i" value="0"/>	
										<c:forEach items="${val.value}" var="_checkbox">																		
										<label class="checkbox-inline">
											<input name="${val.name}" type="checkbox" value="${_checkbox}" <c:if test="${val.def.contains(_checkbox)}">checked="checked"</c:if>>
											<span class="lbl">
												<c:out value="${val.text[i]}"/>	
											</span>
										</label>						
										<c:set var="i" value="${i+1}"/>	
										</c:forEach>													
									</div>
								</div>
							</div>
							</c:if>	
							</c:if>					
							</c:forEach>
							</c:forEach>
						</div>
						<div class="form-footer">
							<div class="form-group">
								<label class="col-xs-3">
								</label>
								<div class="col-xs-9">
									<c:forEach items="${submit}" var="xf">
									<button type="${xf.type}" id="${xf.id}" class="btn btn-sm btn-grey">
										<i class="fa ${xf.icon}">
										</i>
										${xf.title}
									</button>
									</c:forEach>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script>	
		var myform=form.init("myform");	
		$("#save").click(function(){			
			myform.submit(function(res){
				parent.layer.msg(res.msg);
				if(res.code==1 && res.url){
					setTimeout(function(){
	        			var index = parent.layer.getFrameIndex(window.name);
		        		parent.layer.close(index);
		        		parent.location.href=res.url;
	        		},1000);
				}	
				if(res.code==2 && res.url){
					setTimeout(function(){        			
		        		location.href=res.url;
	        		},1000);
				}
			});
		});	
		$("#reset").click(function(){
			myform.reset();
		});
		</script>
	</body>
</html>									